package com.hrg.rds.biz.waybill.domain.template.cmd;

import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum CmdType {

    StartCmd(true, "FLOW", "系统内置", ""),
    EndCmd(true, "FLOW", "系统内置", ""),
    JoinCmd(true, "FLOW", "系统内置", ""),

    SelectAgvCmd(false, "AGV_DISPATCH", "AGV操作", "agvId(String),agvGroupId(String),batteryLevel(Boolean),keyStation(String)"),
    // targetSiteLabel（"value": "AP148"）、scriptName（"value": "CustomCommand"）、custom_customCommandType、custom_customCommandType、custom_scriptName、custom_scriptArgs
    AgvNavCmd(false, "AGV_DISPATCH", "AGV导航", "targetStation(String),onlyOccupiedToCurrent(Boolean),successByDistance(Double),successByStation(Integer)"),
    AgvNavOperationCmd(false, "AGV_DISPATCH", "AGV导航和动作", ",targetStation(String),onlyOccupiedToCurrent(Boolean),operation(String)[preload|load|unload],lowHeight(Double),highHeight(Double)"),
    //参数

    //BreakCmd(false, "FLOW", "控制流程", ""),
    //DelayCmd(false, "FLOW", "控制流程", ""),
    //IfCmd(false, "FLOW", "控制流程", ""),
    //IfElseCmd(false, "FLOW", "控制流程", ""),
    //IfElseIfCmd(false, "FLOW", "控制流程", ""),
    //IteratorCmd(false, "FLOW", "控制流程", ""),
    ConcurrentCmd(false, "FLOW", "控制流程", ""),
    //SequenceCmd(false, "FLOW", "控制流程", ""),
    //RepeatNCmd(false, "FLOW", "控制流程", ""),
    //ReturnCmd(false, "FLOW", "控制流程", ""),

    // 根据实际需要修改 OpenDoorDist 参数；（当机器人距离门 OpenDoorDist 的距离时，RdsCore 对门控模块发出开门请求）
    // 注意：此参数需要根据具体实际进行修改，默认为10m，即当机器人距离门 10m 时，RdsCore 对门控模块发出开门请求；

    // 当 门 开口到位（触发上方的到位DI），机器人正常通过此大门后，大门自动关闭；
    // 具体的流程是小车来到自动门前，如果此时连接正常，那么小车就会发送开门的信号，直到门打开，如果门没有动作，就会一直发送这个开门信号，如果门打开了，并且门打开到位了，小车此时会通过自动门，达到下一个点位时，小车会发送关门信号。
    ModbusReadCmd(false, "DEVICE", "PLC通信", "executeAfterStation(String),ip(String),port(Integer),area(String),address(Integer),offset(Integer),valueType(String),value(String),success(Boolean)"),
    ModbusWriteCmd(false, "DEVICE", "PLC通信", "executeAfterStation(String),ip(String),port(Integer),area(String),address(Integer),offset(Integer),valueType(String),value(String),success(Boolean)"),

    //ModbusWaitCmd(false, "DEVICE", "PLC通信", ""),

    S7ReadCmd(false, "DEVICE", "PLC通信", "executeAfterStation(String),ip(String),port(Integer),area(String),address(Integer),offset(Integer),valueType(String),value(String),success(Boolean)"),
    S7WriteCmd(false, "DEVICE", "PLC通信", "executeAfterStation(String),ip(String),port(Integer),area(String),address(Integer),offset(Integer),valueType(String),value(String),success(Boolean)"),

    //S7WaitCmd(false, "DEVICE", "PLC通信", ""),

    HttpGetCmd(false, "HTTP", "http请求", "executeAfterStation(String),ip(String),port(Integer),path(String),queryString(String),success(Boolean)"),
    HttpPostCmd(false, "HTTP", "http请求", "executeAfterStation(String),ip(String),port(Integer),path(String),queryString(String),value(String),success(Boolean)"),

    
    ;

    // category 流程块、脚本块、任务块、设备块、库位块、基础块、机器人调度块、http请求块、常用参数块
    CmdType(boolean ifHidden, String category, String desc, String cmdTypeParamJson) {
        this.ifHidden = ifHidden;
        this.category = category;
        this.desc = desc;
        this.cmdTypeParamJson = cmdTypeParamJson;
    }
    private final boolean ifHidden;
    private final String category;
    private final String desc;
    private final String cmdTypeParamJson;

    private static final Map<String, CmdType> map;

    static {
        map = new HashMap<>();
        for (CmdType cmdType : CmdType.values()) {
            map.put(cmdType.name(), cmdType);
        }
    }

    public static List<CmdType> getCmdTypes() {
        List<CmdType> cmdTypes = new ArrayList<>();
        for (CmdType cmdType : CmdType.values()) {
            if (!cmdType.ifHidden) {
                cmdTypes.add(cmdType);
            }
        }
        return cmdTypes;
    }
    
}
